import 'package:flutter/material.dart';
import 'package:flutter_ability/custom_ui.dart';

class ImageImgPage extends StatefulWidget {
  const ImageImgPage({Key? key}) : super(key: key);

  @override
  State<ImageImgPage> createState() => _ImageImgPageState();
}

class _ImageImgPageState extends State<ImageImgPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: YJAppBar(
        isScaffold: true,
        leadingType: YJAppBarType.back,
        title: TextView.text("Image 图片"),
        backgroundColor: YJColors.WHITE,
      ),
      backgroundColor: YJColors.WHITE,
      body: buildContainer2(),
    );
  }

  Widget buildContainer2() {
    return Container(
      alignment: Alignment.centerLeft,
      child: SingleChildScrollView(
          child:
              Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
        TextView.text("默认加载"),
        const YJImage(
          "https://www.vipandroid.cn/ming/image/gan.png",
          width: 100,
          fit: BoxFit.scaleDown,
          height: 75,
        ),
        TextView.text("设置宽高拉伸充满"),
        const YJImage(
          "https://www.vipandroid.cn/ming/image/gan.png",
          fit: BoxFit.fill,
          width: 100,
          height: 75,
        ),
        TextView.text("设置宽高居中裁切"),
        const YJImage(
          "https://www.vipandroid.cn/ming/image/gan.png",
          fit: BoxFit.cover,
          width: 100,
          height: 75,
        ),
        TextView.text("设置占位图"),
        const YJImage(
          "https://www.vipandroid.cn/ming/image/gan.png",
          fit: BoxFit.cover,
          placeholderImage: "assets/icon_img7.png",
          width: 100,
          height: 75,
        ),
        TextView.text("设置error图"),
        Container(
          width: 100,
          height: 75,
          color: YJColors.BACKGROUND_COLOR,
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: const [
              YJImage(
                "https://www.vipandroid.cn/ming/image/gan1.png",
                fit: BoxFit.cover,
                placeholderImage: "assets/icon_img7.png",
                errorImage: "assets/icon_error.png",
                width: 41,
                height: 36,
              )
            ],
          ),
        ),
        TextView.text("设置圆角"),
        const YJImage(
          "https://www.vipandroid.cn/ming/image/gan.png",
          fit: BoxFit.cover,
          imageRadius: 20,
          placeholderImage: "assets/icon_error.png",
          width: 100,
          height: 75,
        ),
      ])),
    );
  }

  Container buildContainer() {
    return Container(
      padding: const EdgeInsets.only(top: 20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            color: Color(0xFFFFA2A2),
            height: YJSize.dp(52),
            width: YJSize.screenWidth,
            child: TextView.text("※ 所有插图所在位置，距上个容器距离固定为52"),
          ),
          Container(
            width: YJSize.dp(75),
            height: YJSize.dp(120),
            color: Colors.greenAccent,
            child: YJImage(
              "",
              placeholderImage: "assets/icon_img7.png",
            ),
          ),
          Container(
            color: Color(0xFFFFA2A2),
            height: YJSize.dp(24),
            width: YJSize.screenWidth,
            child: TextView.text("※ 所有插图所在位置，描述文案距插图固定为24"),
          )
        ],
      ),
    );
  }
}
